<script setup lang="ts">
	import { ref, onMounted } from "vue";
	import { formRules } from "./utils/rule";
	import { FormProps } from "./utils/types";
	import ReCol from "@/components/ReCol";
  import { baseUrlApi, baseOaApi } from "@/api/utils";
  import type { UploadProps } from "element-plus";
  import { message } from "@/utils/message";
  import { getDeptListApi, userSelectApi } from "@/api/user"
  import { typeSelect } from "@/api/projectApi"
  import { closeAllDialog } from "@/components/ReDialog/index"
  import { taskBulkStoreApi } from "@/api/taskApi";
  import { ElLoading } from 'element-plus'
  import {
    debounce
  } from "@pureadmin/utils";
  const props = withDefaults(defineProps<FormProps>(), {
  	formInline: () => ({
  		title: "",
  		status: 0,
  		Id: 0,
  	})
  });
	const ruleFormRef = ref();
	const newFormInline = ref(props.formInline);
	function getRef() {
		return ruleFormRef.value;
	}
	defineExpose({ getRef });
  const projectTypeOptions = [
    {id:1,name: '生产'},
    {id:2,name: '生产实施'},
  ]
  const budgetIsPendOptions = [
    {id:0,name:'非待定'},
    {id:1,name:'待定'},
  ]
  const isPrivateOptions = [
    {id:0, name: '公开'},
    {id:1,name: '私有'},
  ]

  const actionUrl = baseUrlApi + "/uploadFile/upload";

  const fileList = ref()
  const imgUrl = ref("");
  const handleAttachmentSuccess: UploadProps["onSuccess"] = (
    response,
    uploadFile
  ) => {
    console.log(response)
    // imgUrl.value = URL.createObjectURL(uploadFile.raw!);
    // newFormInline.value.attachment = baseOaApi + response.result.path;
  };
  const beforeUpload = (file) => {
    const isContract = file.name.endsWith('.pdf') || file.name.endsWith('.doc') || file.name.endsWith('.docx'); // 检查文件类型是否为合同文件类型（例如：PDF, DOC, DOCX）
    const isLt500kb = file.size / 1024 < 500; // 检查文件大小是否小于500kb
    if (!isContract) {
      message("文件格式不支持!", {
        type: "error"
      });
      return false; // 不允许上传非合同文件类型
    }
    // if (!isLt500kb) {
    //   message("上传文件大小不能超过500kb!", {
    //     type: "error"
    //   });
    //   return false; // 不允许上传大于500kb的文件
    // }
    return true;
  }
  const uploadRef = ref()
  const submitUpload = () => {
    uploadRef.value!.submit()
  }
  const onExceed = (files, uploadFiles) => {
    message("已有文件，请先删除已上传文件!", {
      type: "error"
    });
  }

  onMounted(()=> {
    // getDeptList()
    // getTypeSelect()
  })
  const disabledDate = (time, currentIndex) => {
    // 禁用今天之前的日期
    const today = new Date(newFormInline.value.projectInfo.planStartDate);
    today.setHours(0, 0, 0, 0);
    // 禁用早于前一个选择器日期的选项

    let flag = 0;
    for (let item of newFormInline.value.tableList) {
      if(item.children.length > 0){
        if(item.children.length === 3) {
          flag = 1
        }
        if(item.children.length === 6) {
          flag = 2
        }
      }
    }
    if(flag === 2) {
      let endTime = newFormInline.value.tableList[currentIndex - 1]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[currentIndex - 1]?.rangePlanDate[1]:null
      if(currentIndex === 9) {
        endTime = newFormInline.value.tableList[2]?.rangePlanDate[0] !== '--' ? newFormInline.value.tableList[1]?.rangePlanDate[1]:null

      } else if(currentIndex === 10) {

        endTime = newFormInline.value.tableList[3]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[3]?.rangePlanDate[1]:null
      } else if(currentIndex === 11) {
        endTime = newFormInline.value.tableList[4]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[4]?.rangePlanDate[1]:null
      } else if(currentIndex === 12) {
        endTime = newFormInline.value.tableList[5]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[5]?.rangePlanDate[1]:null
      } else if(currentIndex === 13) {
        endTime = newFormInline.value.tableList[6]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[6]?.rangePlanDate[1]:null
      } else if(currentIndex === 14) {
        endTime = newFormInline.value.tableList[7]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[7]?.rangePlanDate[1]:null
      } else if(currentIndex === 15) {
        endTime = newFormInline.value.tableList[8]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[8]?.rangePlanDate[1]:null
      }
      const prevDate = new Date(endTime);
      return time.getTime() < prevDate.getTime() || time.getTime() < today.getTime();
    }
    if(flag === 1) {
      let endTime = newFormInline.value.tableList[currentIndex - 1]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[currentIndex - 1]?.rangePlanDate[1]:null
      if(currentIndex === 6) {
        endTime = newFormInline.value.tableList[2]?.rangePlanDate[0] !== '--' ? newFormInline.value.tableList[2]?.rangePlanDate[1]:null
      } else if(currentIndex === 7) {
        // endTime = newFormInline.value.tableList[3]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[3]?.rangePlanDate[1]:null
      } else if(currentIndex === 8) {
        endTime = newFormInline.value.tableList[4]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[4]?.rangePlanDate[1]:null
      } else if(currentIndex === 9) {
        endTime = newFormInline.value.tableList[5]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[5]?.rangePlanDate[1]:null
      } else if(currentIndex === 10) {
        endTime = newFormInline.value.tableList[6]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[6]?.rangePlanDate[1]:null
      } else if(currentIndex === 11) {
        endTime = newFormInline.value.tableList[7]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[7]?.rangePlanDate[1]:null
      } else if(currentIndex === 12) {
        endTime = newFormInline.value.tableList[8]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[8]?.rangePlanDate[1]:null
      }
      const prevDate = new Date(endTime);
      return time.getTime() < prevDate.getTime() || time.getTime() < today.getTime();
    }
    if (currentIndex > 0) {
      let endTime = newFormInline.value.tableList[currentIndex - 1]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[currentIndex - 1]?.rangePlanDate[1]:null
      const prevDate = new Date(endTime);
      return time.getTime() < prevDate.getTime() || time.getTime() < today.getTime();
    }
    return time.getTime() < today.getTime();
  }
  const specialDisabledDate = (time, currentIndex) => {
    const today = new Date(newFormInline.value.projectInfo.planStartDate);
    today.setHours(0, 0, 0, 0);
    if(newFormInline.value.tableList[2].children.length === 6) {

      let endTime = null
      if(currentIndex === 3 || currentIndex === 6) {
        endTime = newFormInline.value.tableList[1]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[1]?.rangePlanDate[1]:null
      } else if(currentIndex === 4) {
        endTime = newFormInline.value.tableList[2]?.children[0].rangePlanDate?.length > 0 ? newFormInline.value.tableList[2]?.children[0].rangePlanDate[1]:null
      } else if(currentIndex === 5) {
        endTime = newFormInline.value.tableList[2]?.children[1].rangePlanDate?.length > 0 ? newFormInline.value.tableList[2]?.children[1].rangePlanDate[1]:null
      } else if(currentIndex === 7) {
        endTime = newFormInline.value.tableList[2]?.children[3].rangePlanDate?.length > 0 ? newFormInline.value.tableList[2]?.children[3].rangePlanDate[1]:null
      } else if(currentIndex === 8) {
        endTime = newFormInline.value.tableList[2]?.children[4].rangePlanDate?.length > 0 ? newFormInline.value.tableList[2]?.children[4].rangePlanDate[1]:null
      } else {
        endTime = newFormInline.value.tableList[currentIndex - 1]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[currentIndex - 1]?.rangePlanDate[1]:null
      }

      const prevDate = new Date(endTime);
      return time.getTime() < prevDate.getTime() || time.getTime() < today.getTime();
    }
    if(newFormInline.value.tableList[2].children.length === 3) {

      let endTime = null
      if(currentIndex === 3) {
        endTime = newFormInline.value.tableList[1]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[1]?.rangePlanDate[1]:null
      } else if(currentIndex === 4) {
        endTime = newFormInline.value.tableList[2]?.children[0].rangePlanDate?.length > 0 ? newFormInline.value.tableList[2]?.children[0].rangePlanDate[1]:null
      } else if(currentIndex === 5) {
        endTime = newFormInline.value.tableList[2]?.children[1].rangePlanDate?.length > 0 ? newFormInline.value.tableList[2]?.children[1].rangePlanDate[1]:null
      } else if(currentIndex === 7) {
        endTime = newFormInline.value.tableList[2]?.children[3].rangePlanDate?.length > 0 ? newFormInline.value.tableList[2]?.children[3].rangePlanDate[1]:null
      } else if(currentIndex === 8) {
        endTime = newFormInline.value.tableList[2]?.children[4].rangePlanDate?.length > 0 ? newFormInline.value.tableList[2]?.children[4].rangePlanDate[1]:null
      } else {
        endTime = newFormInline.value.tableList[currentIndex - 1]?.rangePlanDate?.length > 0 ? newFormInline.value.tableList[currentIndex - 1]?.rangePlanDate[1]:null
      }
      const prevDate = new Date(endTime);
      return time.getTime() < prevDate.getTime() || time.getTime() < today.getTime();
    }

    return time.getTime() < today.getTime();
  }
  let taskTypeSelect = ref([

  ])
  const statusSelect = [
    {id: 0, name: '未开始'},
    {id: 1, name: '进行中'},
    {id: 2, name: '已完成'},
    {id: 3, name: '已关闭'},
  ]
  const calculateWorkingHours = (s, e) => {
    // const start = new Date(s);
    // const end = new Date(e);
    // let totalHours = 0;
    // let currentDate = new Date(start);
    // const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds

    // while (currentDate <= end) {
    //   const day = currentDate.getDay(); // 获取星期几，0为周日，1为周一，以此类推
    //   if (day !== 0 && day !== 6) { // 如果不是周六或周日，则计入总小时数（这里假设每天工作8小时）
    //     totalHours += 8; // 这里假定每天工作8小时，可以根据需要调整
    //   }
    //   currentDate = new Date(currentDate.getTime() + oneDay); // 加一天的时间跨度
    // }
    // return totalHours; // 设置工作日小时数到数据属性中
    const start: any = new Date(s);
    const end: any = new Date(e);
    const diffTime = Math.abs(end - start);
    const diffHours = diffTime / (1000 * 60 * 60); // 毫秒转换为小时
    return diffHours.toFixed(2); // 四舍五入到小数点后两位
  }
  const datePickerChange = (val, row) => {
    if(val) {
      row.expectHour = calculateWorkingHours(val[0], val[1])
    }
    let startDate1: any = newFormInline.value.tableList[2].children[0].rangePlanDate && newFormInline.value.tableList[2].children[0].rangePlanDate[0] !== '--' ? newFormInline.value.tableList[2].children[0].rangePlanDate[0] : '';
    let startDate2 = null;
    let endDate1 = newFormInline.value.tableList[2].children[2].rangePlanDate && newFormInline.value.tableList[2].children[2].rangePlanDate[1] !== '--' ? newFormInline.value.tableList[2].children[2].rangePlanDate[1]: '';
    let endDate2 = null
    if(newFormInline.value.tableList[2].children.length > 3){
      startDate2 = newFormInline.value.tableList[2].children[3].rangePlanDate && newFormInline.value.tableList[2].children[3].rangePlanDate[0] !== '--' ? newFormInline.value.tableList[2].children[3].rangePlanDate[0]: '';
      endDate2 = newFormInline.value.tableList[2].children[5].rangePlanDate && newFormInline.value.tableList[2].children[5].rangePlanDate[1] !== '--' ? newFormInline.value.tableList[2].children[5].rangePlanDate[1]: '';
    }
    if(new Date(startDate1) <= new Date(startDate2)) {
      if(new Date(endDate1) <= new Date(endDate2) && newFormInline.value.tableList[2].children.length > 3) {
        newFormInline.value.tableList[2].rangePlanDate = [newFormInline.value.tableList[2].children[0].rangePlanDate[0],newFormInline.value.tableList[2].children[5].rangePlanDate[1]]
      } else {
        newFormInline.value.tableList[2].rangePlanDate = [newFormInline.value.tableList[2].children[0].rangePlanDate[0],newFormInline.value.tableList[2].children[2].rangePlanDate[1]]
      }

    } else {
      if(newFormInline.value.tableList[2].children.length > 3) {
        if(new Date(endDate1) <= new Date(endDate2)) {
          newFormInline.value.tableList[2].rangePlanDate = [newFormInline.value.tableList[2].children[5].rangePlanDate[0],newFormInline.value.tableList[2].children[5].rangePlanDate[1]]
        } else if(new Date(endDate1) > new Date(endDate2)) {
          newFormInline.value.tableList[2].rangePlanDate = [newFormInline.value.tableList[2].children[5].rangePlanDate[0],newFormInline.value.tableList[2].children[2].rangePlanDate[1]]
        }
      } else {
        newFormInline.value.tableList[2].rangePlanDate = [newFormInline.value.tableList[2].children[0].rangePlanDate[0],newFormInline.value.tableList[2].children[2].rangePlanDate[1]]
      }

    }
    if(newFormInline.value.tableList[2].rangePlanDate[0] !== '--') {
      newFormInline.value.tableList[2].expectHour = calculateWorkingHours(newFormInline.value.tableList[2].rangePlanDate[0], newFormInline.value.tableList[2].rangePlanDate[1])
    }
  }
  const departmentList = ref()
  const getDeptList = async() => {
    // const res = await getDeptListApi();
    // departmentList.value = res?.result ?? []
    // if(departmentList.value && departmentList.value.length > 0) {
    //   for (let item of departmentList.value) {
    //     for (let user of newFormInline.value.userSelect) {

    //     }
    //   }
    // }
    const res = await getDeptListApi();
    const userList = await userSelectApi();
    if(res?.code === 200 && userList?.code === 200) {
      for (let item of res.result ?? []) {
        item.children = []
        for (let user of userList?.result ?? []) {
          if(item.id === user.department?.id) {
            item.children.push({
              id: user.userId,
              name: user.name,
              username: user.username,
            })
          }
        }
      }
    }
    let arr = [];
    for (let item of res?.result ?? []) {
      if(item.children.length > 0) {
        arr.push(item)
      }
    }
    departmentList.value = arr
  }

  const getTypeSelect = async() => {
    const res: any = await typeSelect()
    taskTypeSelect.value = res?.result ?? []
  }
  const defaultTime = [new Date(2000, 1, 1, 8, 30, 0), new Date(2000, 1, 1, 18, 0, 0),]
  const assignedToChange = (val) => {
    let arr = []
    for (let item of newFormInline.value.tableList) {
      for (let row of item.children) {
        for (let child of row.assignedTo) {
          arr.push(child)
        }
      }
    }
    newFormInline.value.tableList[2].assignedTo = [...new Set(arr)]
  }
  const getRowClassName = ({row, rowIndex}) => {
    if (rowIndex === 2) { // 假设你要修改第三行（索引为2）
      return 'custom-row-tr';
    }
    return '';
  }
  // 删除参数为空的键值
  function cleanEmptyData(obj: object) {
    Object.keys(obj).forEach(key => {
      if (obj[key] === null || obj[key] === '') {
        delete obj[key];
      }
    });
    return obj
  }
  const closeDialog = () => {
    closeAllDialog()
  }

  const realTimeCroppered = () => {
    let params = {
      projectId: newFormInline.value.projectInfo.projectId,
      taskList: [],
      projectStatus: newFormInline.value.status === 0 || newFormInline.value.status === 2? 1 : null
    }
    for (let item of newFormInline.value.tableList) {
      if(!item.taskType) {
        message("请选择任务类型", {
          type: "error"
        });
        return
      }
      if(!item.assignedTo) {
        message("请选择指派用户", {
          type: "error"
        });
        return
      }
      if(!item.rangePlanDate) {
        message("请选择计划日期", {
          type: "error"
        });
        return
      }
      if(!item.priority) {
        message("请输入优先级", {
          type: "error"
        });
        return
      }
      if(!item.expectHour) {
        message("请输入预计小时", {
          type: "error"
        });
        return
      }
    }
    let child = []
    for (let item of newFormInline.value.tableList) {
      if(item.children && item.children.length > 0) {
        for (let row of item.children) {
          child.push({
            taskId: row.taskId,
            taskType: row.taskType,
            parentId: row.parentId,
            hasMultiUser: row.assignedTo.length >1?1:0,
            assignedTo: row.assignedTo,
            planStartDate: (row.rangePlanDate[0].match(/:/g) || []).length ===1?row.rangePlanDate[0]+':00':row.rangePlanDate[0],
            planEndDate: (row.rangePlanDate[1].match(/:/g) || []).length ===1?row.rangePlanDate[1]+':00':row.rangePlanDate[1],
            priority: row.priority,
            expectHour: row.expectHour,
            description: row.description,
            keyword: row.keyword,
            assignedExtraTo: row.assignedExtraTo ?? [],
            completeRate: row.completeRate,
          })
        }
      }


      params.taskList.push({
        taskId: item.taskId,
        taskType: item.taskType,
        parentId: 0,
        hasMultiUser: item.assignedTo.length >1?1:0,
        assignedTo: item.assignedTo,
        planStartDate: (item.rangePlanDate[0].match(/:/g) || []).length ===1?item.rangePlanDate[0]+':00':item.rangePlanDate[0],
        planEndDate: (item.rangePlanDate[1].match(/:/g) || []).length ===1?item.rangePlanDate[1]+':00':item.rangePlanDate[1],
        priority: item.priority,
        expectHour: item.expectHour,
        description: item.description,
        keyword: item.keyword,
        // attachment: [baseOaApi + item.fileList[0].response.result.path],
        assignedExtraTo: item.assignedExtraTo ?? [],
        completeRate: item.completeRate,

      })
    }
    params.taskList = [...params.taskList, ...child]
    params.taskList.sort((a, b) => a.taskType - b.taskType)
    const elLoading = ElLoading.service({
      lock: true,
      text: 'Loading',
      background: 'rgba(0, 0, 0, 0.7)',
    })
    taskBulkStoreApi(cleanEmptyData(params)).then((res: any) => {
      if(res?.code ===200) {
        closeDialog();
        newFormInline.value.fn()
      }
      elLoading.close()
    })
    .catch(error => {
      elLoading.close()
      message(error.response.data.msg ?? "操作失败,请联系管理员", {
        type: "error"
      });
    });
  }
  const saveSubmit = debounce(realTimeCroppered, 300);
</script>

<template>
	<el-form ref="ruleFormRef" :model="newFormInline" :rules="formRules" label-width="auto" class="taskForm">
    <!-- <div class="flex">
      <div>项目名称：{{newFormInline.projectInfo.projectName}}</div>
      <div class="ml-[30px]">项目编码：{{newFormInline.projectInfo.projectNo}}</div>
      <div class="ml-[30px]">计划日期：{{newFormInline.projectInfo.planStartDate}} 至 {{newFormInline.projectInfo.planEndDate}}</div>
    </div>
    <hr> -->

		<el-table :data="newFormInline.tableList" row-key="taskType" style="width: 100%;" :show-overflow-tooltip="true" ref="tableRef" default-expand-all :row-class-name="getRowClassName">

		  <!-- <el-table-column label="所属项目" prop="projectName" :minWidth="200">
        <template #default="scope">
          {{scope.row.children}}
        </template>
      </el-table-column> -->
		  <el-table-column label="任务类型" prop="projectNo" :minWidth="170">
        <template #default="scope">
          <!-- <el-form-item > -->
            <!-- <el-select
              v-model="scope.row.taskType"
              placeholder="请选择"
              disabled
            >
              <el-option
                v-for="item in newFormInline.taskTypeSelect"
                :key="item.value"
                :label="item.name"
                :value="item.value"
              />
            </el-select> -->
            <!-- <el-input v-model="scope.row.taskTypeName" disabled/> -->

          <!-- </el-form-item> -->
          {{scope.row.taskTypeName}}
        </template>
      </el-table-column>
		  <el-table-column label="指派用户" prop="projectType" :minWidth="340">
		    <template #default="{row, $index}">
          <template v-if="row.children && row.children.length > 0">
            <el-form-item :prop="'tableList.' + $index + '.assignedTo'">
              <el-select
                v-model="row.assignedTo"
                placeholder="请选择"
                clearable
                filterable
                multiple
                collapse-tags
                collapse-tags-tooltip
                :max-collapse-tags="2"
                :disabled="row.children && row.children.length > 0"
              >
                <el-option
                  v-for="item in newFormInline.userSelect"
                  :key="item.userId"
                  :label="item.name"
                  :value="item.userId"
                />
              </el-select>

              <!-- <el-cascader
                v-model="row.assignedTo"
                class="w-full "
                popper-class="last-check"
                :options="departmentList"
                :props="{
                  value: 'id',
                  label: 'name',
                  multiple: true
                }"
                clearable
                placeholder="请选择"
                :show-all-levels="false"
                collapse-tags
                collapse-tags-tooltip
                >
                <template #default="{ node, data }">
                  <span>{{ data.name }}</span>
                  <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
                </template>
              </el-cascader> -->
            </el-form-item>
          </template>
          <template v-else>
            <el-form-item :prop="'tableList.' + $index + '.assignedTo'">
              <el-select
                v-model="row.assignedTo"
                placeholder="请选择"
                clearable
                filterable
                multiple
                collapse-tags
                collapse-tags-tooltip
                :max-collapse-tags="2"
                @change="assignedToChange"
              >
                <el-option
                  v-for="item in newFormInline.userSelect"
                  :key="item.userId"
                  :label="item.name"
                  :value="item.userId"
                />
              </el-select>
            </el-form-item>
          </template>
		    </template>
		  </el-table-column>
		  <el-table-column label="计划日期" :minWidth="380">
        <template #default="{row, $index}">
          <el-form-item :prop="'tableList.' + $index + '.rangePlanDate'">
            <template v-if="row.children && row.children.length > 0 || row.parentId > 0">
            <!-- :disabled-date="(time) => specialDisabledDate(time, $index)" -->
              <el-date-picker
                v-model="row.rangePlanDate"
                type="datetimerange"
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                format="YYYY-MM-DD HH:mm"
                value-format="YYYY-MM-DD HH:mm"
                @change="(val)=>{datePickerChange(val, row)}"
                :default-time="defaultTime"

                time-format="HH:mm"
                :disabled="row.children && row.children.length > 0"
              />
            </template>
            <!-- :disabled-date="(time) => disabledDate(time, $index)" -->
            <template v-else>
              <el-date-picker
                v-model="row.rangePlanDate"
                type="datetimerange"
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                format="YYYY-MM-DD HH:mm"
                value-format="YYYY-MM-DD HH:mm"
                @change="(val)=>{datePickerChange(val, row)}"
                :default-time="defaultTime"

                time-format="HH:mm"

              />
            </template>

          </el-form-item>
        </template>
      </el-table-column>
		  <el-table-column label="优先级" :minWidth="120">
        <template #default="{row, $index}">
          <el-form-item :prop="'tableList.' + $index + '.priority'">
          	<el-input-number
          		v-model="row.priority"
          		class="!w-full"
          		:min="0"
          		:max="4"
          		controls-position="right"
              :precision="0"

          	  />
          </el-form-item>
        </template>
      </el-table-column>
		  <el-table-column label="预计小时" :minWidth="100">
		    <template #default="{row, $index}">
		      <el-form-item :prop="'tableList.' + $index + '.expectHour'">
		      	<el-input v-model="row.expectHour" />
		      </el-form-item>
		    </template>
		  </el-table-column>
		  <el-table-column label="描述" prop="description" :minWidth="200">
		    <template #default="{row, $index}">
		      <el-form-item :prop="'tableList.' + $index + '.description'">
		      	<el-input v-model="row.description" clearable placeholder="请输入描述" />
		      	<!-- <el-input v-model="row.description" type="textarea" clearable placeholder="请输入描述" :rows="2"/> -->
		      </el-form-item>
		    </template>
		  </el-table-column>
		  <el-table-column label="关键词" prop="keyword" :minWidth="200">
        <template #default="{row, $index}">
          <el-form-item :prop="'tableList.' + $index + '.keyword'">
          	<el-input v-model="row.keyword" clearable placeholder="请输入关键词" />
          </el-form-item>
        </template>
      </el-table-column>
		  <!-- <el-table-column label="附件" prop="attachment" :minWidth="380">
        <template #default="{row, $index}">
          <el-form-item :prop="'tableList.' + $index + '.attachment'">
          	<el-upload
          	  ref="uploadRef"
          	  :action="actionUrl"
          	  :on-success="handleAttachmentSuccess"
          	  :on-exceed="onExceed"
          	  v-model:file-list="row.fileList"
          	  :before-upload="beforeUpload"
          	  :limit="1"
          	  multiple>
          	  <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传文件</el-button>
          	  <div slot="tip" class="el-upload__tip">只能上传合同文件，格式为pdf,doc,docx</div>
          	</el-upload>
          </el-form-item>
        </template>
      </el-table-column> -->
		  <el-table-column label="抄送给用户" prop="assignedExtraTo" :minWidth="180">
        <template #default="{row, $index}">
          <el-form-item :prop="'tableList.' + $index + '.assignedExtraTo'">
          	<el-select
          	  v-model="row.assignedExtraTo"
          	  placeholder="请选择"
          	  clearable
              filterable
          	  multiple
              collapse-tags
              collapse-tags-tooltip
              :max-collapse-tags="1"

          	>
          	  <el-option
          	    v-for="item in newFormInline.userSelect"
          	    :key="item.userId"
          	    :label="item.name"
          	    :value="item.userId"
          	  />
          	</el-select>
            <!-- <el-cascader
              v-model="row.assignedExtraTo"
              class="w-full "
              popper-class="last-check"
              :options="departmentList"
              :props="{
                value: 'id',
                label: 'name',
                multiple: true
              }"
              clearable
              placeholder="请选择"
              :show-all-levels="false"
              collapse-tags
                    collapse-tags-tooltip
              >
              <template #default="{ node, data }">
                <span>{{ data.name }}</span>
                <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
              </template>
            </el-cascader> -->
          </el-form-item>
        </template>
      </el-table-column>
		  <!-- <el-table-column label="状态" prop="status" :minWidth="130">
		    <template #default="{row, $index}">
		      <el-form-item :prop="'tableList.' + $index + '.status'">
		      	<el-select
		      	  v-model="row.status"
		      	  placeholder="请选择"
		      	  clearable
		      	>
		      	  <el-option
		      	    v-for="item in statusSelect"
		      	    :key="item.id"
		      	    :label="item.name"
		      	    :value="item.id"
		      	  />
		      	</el-select>
		      </el-form-item>
		    </template>
		  </el-table-column> -->
		 <!-- <el-table-column label="完成比例" prop="completeRate" :minWidth="120">
		    <template #default="{row, $index}">
		      <el-form-item :prop="'tableList.' + $index + '.completeRate'">
		      	<el-input-number
		      		v-model="row.completeRate"
		      		class="!w-full"
		      		:min="0"
		      		:max="100"
		      		controls-position="right"
		          :precision="0"
              :step="5"

		      	  />
		      </el-form-item>
		    </template>
		  </el-table-column> -->
		</el-table>
    <div class="flex mt-[20px]" style="justify-content: right;">

      <el-button text bg @click="closeDialog">
        取消
      </el-button>
      <el-button type="primary" text bg @click="saveSubmit">
        保存
      </el-button>
      <el-button type="success" text bg v-if="newFormInline.status === 0 || newFormInline.status === 2" @click="saveSubmit">
        保存并启动
      </el-button>
    </div>
	</el-form>

</template>
<style lang="scss">
  .last-check {
    li[aria-haspopup="true"] {
      .el-checkbox {
        display: none;
      }
    }
  }
</style>
<style scoped>
  .taskForm {
    margin-bottom: 22px;
  }
  .taskForm :deep(.el-form-item) {
    margin-bottom: 0;
  }
  :deep(.dialogTable .el-table__inner-wrapper:before) {
    background-color: var(--el-table-border-color) !important;
  }
  :deep(.el-table .el-table__row--level-1 td:nth-child(1)) {
    border-bottom: none;
  }
  :deep(.el-table .custom-row-tr + .el-table__row--level-1 + .el-table__row--level-1 + .el-table__row--level-1 td:nth-child(1)),
  :deep(.el-table .custom-row-tr + .el-table__row--level-1 + .el-table__row--level-1 + .el-table__row--level-1 + .el-table__row--level-1 + .el-table__row--level-1 + .el-table__row--level-1 td:nth-child(1)){
    border-bottom: 1px solid #ebeef5;
  }
</style>
